'''
本周作业内容如下：
假设小偷有一个背包，最多能装20公斤赃物，他闯入一户人家，发现如下表所示的物品。
很显然，他不能把所有物品都装进背包，所以必须确定拿走哪些物品，留下哪些物品。
名称	价格（美元）    重量（kg）
电脑	    200	            20
收音机	    20	            4
钟	        175	            10
花瓶	    50	            2
书	        10	            1
油画	    90	            9
'''
def main():
    item_information=[["序号","名称","价格","重量"],[1,"电脑",200,20],[2,"收音机",20,4],
                      [3,"钟",175,10],[4,"花瓶",50,2],[5,"书",10,1],[6,"油画",90,9]]#赃物信息
    item_price=[200,20,175,50,10,9]#赃物价格-max
    item_weight=[20,4,10,2,1,9]#赃物重量-20
    bag_information=[["序号","名称","数量","总价格","总重量"]]#背包负担
    price = 0#price=200a+20b+175c+50d+10e+90f
    weight = 20#weight=20a+4b+10c+2d+e+9f
    print("赃物信息：")
    for i in range(0,7):
        for j in range(0,4):
            if j==3:
                print(item_information[i][j])
            else:
                print(item_information[i][j], end='-')
    # for ai in range(0,2):
    #     for bi in range(0,6):
    #         for ci in range(0, 3):
    #             for di in range(0, 11):
    #                 for ei in range(0, 21):
    #                     for fi in range(0,3):
    for ai in range(0, 2):
        for bi in range(0, 2):
            for ci in range(0, 2):
                for di in range(0, 2):
                    for ei in range(0, 2):
                        for fi in range(0, 2):
                            if 20*ai+4*bi+10*ci+2*di+ei+9*fi<=weight:
                                price_=200*ai+20*bi+175*ci+50*di+10*ei+90*fi
                                if price < price_:
                                    price = price_
                                    a=ai
                                    b=bi
                                    c=ci
                                    d=di
                                    e=ei
                                    f=fi
    bag_information = bag_information + [[1, "电脑", a, 200 * a, 20 * a]]
    bag_information = bag_information + [[2, "收音机", b, 20 * b, 4 * b]]
    bag_information = bag_information + [[3, "钟", c, 175 * c, 10 * c]]
    bag_information = bag_information + [[4, "花瓶", d, 50 * d, 2 * d]]
    bag_information = bag_information + [[5, "书", e, 10 * e, e]]
    bag_information = bag_information + [[6, "油画", f, 90 * f, 9 * f]]
    print("背包信息：")
    for i in range(0,7):
        for j in range(0,5):
            if j==4:
                print(bag_information[i][j])
            else:
                print(bag_information[i][j], end='-')
    print("总利润：{}".format(price))
if __name__ == '__main__':
    main()
    """
    for的嵌套太多了，可不可以优化下？
    """